﻿@model UserProfile
@{
    ViewBag.Title = "My Training";
    //show nearest module in the future first
    var upcoming = Model.Interop.UpcomingModules().ToList();
    //show the most recent module first
    var past = Model.Interop.PastModules().ToList();
    var videos = Model.Interop.Videos().ToList();
}
<p>@Html.ActionLink("Edit Contact Information", "EditProfile", "Account") | @Html.ActionLink("Change Password", "ChangePassword", "Account") | @Html.ActionLink("Order History", "Orders")</p>
<div class="mytraining">
    <fieldset>
        <legend>My Videos</legend>
        @if (videos.Count > 0)
        {
            <p class="padtop">Watch your videos by clicking on the video title.</p>
            <table class="videos">
                <thead>
                    <tr>
                        <th>Video</th>
                        <th>Description</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var v in videos)
                    {
                        <tr>
                            <td>@v.LinkToItem(Html, v.Title)</td>
                            <td class="markup">@Html.Raw(v.Teaser)</td>
                        </tr>
                    }
                </tbody>
            </table>
        }
        else
        {
            <p class="padtop">You currently have no videos. @Html.ActionLink("View all videos", "Videos", "Home").</p>
        }
    </fieldset>
    <fieldset>
        <legend>Upcoming Modules</legend>
        <p class="padtop">Below are the modules that you are currently registered for.</p>
        @if (upcoming.Count > 0)
        {
            Html.RenderPartial("ListOfModules", upcoming);
        }
        else
        {
            <p>You currently have no upcoming modules. @Html.ActionLink("View all modules", "Modules", "Home").</p>
        }
    </fieldset>
    @if (past.Count > 0)
    {
        <fieldset>
            <legend>Past Modules</legend>
            <p class="padtop">Help us improve the quality of our modules by providing feedback for your past modules.</p>
            <table>
                <thead>
                    <tr>
                        <th>Title</th>
                        <th>Description</th>
                        <th>Date</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var m in past)
                    {
                        <tr>
                            <td>@m.Title</td>
                            <td class="markup">@Html.Raw(m.Teaser)</td>
                            <td>@m.Start.ToShortDateString()</td>
                            <td>@Html.ActionLink("Leave Feedback", "ModuleFeedback", new { id = m.Id })</td>
                        </tr>
                    }
                </tbody>
            </table>
       </fieldset>
    }
</div>